package piwan;

import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

public class StateHandler extends EventHandler  {
	public StateHandler( int n ) { 
		hdls = new EventHandler[n];
		state = 0;
	}
	
	public void setHandler( EventHandler h, int i ) { hdls[i] = h; }
	public void setState( int newState ) { hdls[state].deactivated(); state = newState; hdls[state].activated(); }
	public EventHandler getHandler() { return hdls[state]; }
	
	public boolean onMousePressed(MouseEvent ev) { return hdls[state].onMousePressed(ev); }
	public boolean onMouseReleased(MouseEvent ev) { return hdls[state].onMouseReleased(ev); }
	public boolean onMouseMotion(MouseEvent ev) { return hdls[state].onMouseMotion(ev); }
	public boolean onKeyPressed( KeyEvent ev ) { return hdls[state].onKeyPressed(ev); }
	public boolean onKeyReleased( KeyEvent ev ) { return hdls[state].onKeyReleased(ev); }
	public boolean onMouseWheel( MouseWheelEvent ev ) { return hdls[state].onMouseWheel(ev); }
	
	public boolean onQuit() { return hdls[state].onQuit(); }
	
	private EventHandler[] hdls;
	private int state;
}
